
#ifndef ______________WARD_FORCE_CPP
#define ______________WARD_FORCE_CPP

#include "Force.h"
#include "Troop.h"




//add n troops to this force, with an average readiness of rdy (in range [1,10])
void Force::add(int n, int rdy)
{
int i;

for(i = 0; i < n; i++)
{
//	ready = max(10,min(1,((rand()%(rdy*2))+1)));
	men.push_back(Troop(rdy));
}

}


//remove some troops from this force and return it
Force Force::split(int n)
{
Force ret(this->owner);

//merge n troops from this into the split force
merge(ret,*this,n);

return ret;
}
	
//removes n troops
void Force::destroy(int n)
{
men.resize(men.size() - n);

}

//returns a (sorted) vector of attack values
vector <int> Force::attack()
{
vector <int> ret(MAX_ROLL);

unsigned int i;
for(i = 0; i < men.size(); i++)
{
	ret[men[i].getRoll()-1]++;
}

return ret;
}

//returns a (sorted) vector of attack values
vector <int> Force::attack(int n, int mod)
{
	vector <int> ret(MAX_ROLL+mod);
	for(int i = 0; i < min((int)n,(int)men.size()); i++)
	{
		int idx = max(0,(men[i].getRoll()-1)+mod);
		ret[idx]++;
	}
	return ret;
}


void Force::train(int n)
{
	unsigned int i = 0;
	int count = 0;
	while((i < men.size())&&(count < n))
	{
		if(men[i].getReadiness() < 5) { men[i].setReadiness(men[i].getReadiness()+1); count++; }
		i++;
	}
}






#endif